// Decompiled by GOOSIN CO,LTD Copyright 2010 Pavel Kouznetsov.
// home page: http://www.Goosin.net
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   check_delete_ok.java

package purchase.file;

import include.nseer_cookie.counter;
import include.nseer_db.nseer_db_backup1;
import java.io.IOException;
import java.sql.ResultSet;
import javax.servlet.ServletException;
import javax.servlet.http.*;
import validata.ValidataNumber;
import validata.ValidataTag;

public class check_delete_ok extends HttpServlet
{

	public check_delete_ok()
	{
	}

	public synchronized void service(HttpServletRequest request, HttpServletResponse response)
		throws IOException, ServletException
	{
		try
		{
			HttpSession dbSession = request.getSession();
			javax.servlet.ServletContext dbApplication = dbSession.getServletContext();
			nseer_db_backup1 purchase_db = new nseer_db_backup1(dbApplication);
			nseer_db_backup1 purchase_db1 = new nseer_db_backup1(dbApplication);
			ValidataNumber validata = new ValidataNumber();
			ValidataTag vt = new ValidataTag();
			counter count = new counter(dbApplication);
			if (purchase_db.conn((String)dbSession.getAttribute("unit_db_name")) && purchase_db1.conn((String)dbSession.getAttribute("unit_db_name")))
			{
				String config_id = request.getParameter("config_id");
				String provider_ID = request.getParameter("provider_ID");
				String choice = request.getParameter("choice");
				String checker_ID = request.getParameter("checker_ID");
				String checker = request.getParameter("checker");
				String check_time = request.getParameter("check_time");
				String sql6 = (new StringBuilder("select id from purchase_workflow where object_ID='")).append(provider_ID).append("' and ((check_tag='0' and config_id<'").append(config_id).append("') or (check_tag='1' and config_id='").append(config_id).append("'))").toString();
				ResultSet rs6 = purchase_db.executeQuery(sql6);
				if (!rs6.next() && vt.validata((String)dbSession.getAttribute("unit_db_name"), "purchase_file", "provider_ID", provider_ID, "excel_tag").equals("1"))
				{
					if (choice != null)
					{
						if (choice.equals(""))
						{
							String sql = (new StringBuilder("update purchase_file set check_tag='9' where provider_ID='")).append(provider_ID).append("'").toString();
							purchase_db.executeUpdate(sql);
							sql = (new StringBuilder("delete from purchase_workflow where object_ID='")).append(provider_ID).append("'").toString();
							purchase_db.executeUpdate(sql);
						} else
						{
							sql6 = (new StringBuilder("select id from purchase_workflow where object_ID='")).append(provider_ID).append("' and config_id<'").append(config_id).append("' and config_id>='").append(choice).append("'").toString();
							String sql;
							for (rs6 = purchase_db.executeQuery(sql6); rs6.next(); purchase_db1.executeUpdate(sql))
								sql = (new StringBuilder("update purchase_workflow set check_tag='0' where id='")).append(rs6.getString("id")).append("'").toString();

						}
						response.sendRedirect("purchase/file/check_delete_ok.jsp?finished_tag=0");
					} else
					{
						response.sendRedirect("purchase/file/check_delete_ok.jsp?finished_tag=1");
					}
				} else
				{
					response.sendRedirect("purchase/file/check_delete_ok.jsp?finished_tag=2");
				}
				purchase_db.commit();
				purchase_db1.commit();
				purchase_db.close();
				purchase_db1.close();
			} else
			{
				response.sendRedirect("error_conn.htm");
			}
		}
		catch (Exception ex)
		{
			ex.printStackTrace();
		}
	}
}
